<template>
  <div class="container">
    <el-dialog title="订单详情" :visible.sync="particularsDialogs.centerDialogVisible" @open="getData" center width="1200px">
      <el-table :data="tableData" border style="width: 100%" empty-text="暂无数据">
        <el-table-column prop="goods_name" label="商品名" align="center"></el-table-column>
        <el-table-column prop="erp_goods_code" label="商品编码" align="center"></el-table-column>
        <el-table-column prop="goods_spec" label="规格" align="center"></el-table-column>
        <el-table-column prop="category_code" label="分类编码" align="center"></el-table-column>
        <el-table-column prop="category_name" label="分类名称" align="center"></el-table-column>
        <el-table-column prop="goods_unit" label="单位" align="center"></el-table-column>
        <el-table-column prop="bar_code" label="条形码" align="center"></el-table-column>
        <el-table-column prop="purchasePrice" v-if="!is_assign" label="采购加价" align="center"></el-table-column>
        <el-table-column v-else prop="purchasePrices" label="采购加价" align="center"></el-table-column>
        <el-table-column v-if="!is_assign" prop="avg_price" label="平均价" align="center"></el-table-column>
        <el-table-column v-else prop="cost_price" label="成本价" align="center"></el-table-column>

        <el-table-column prop="cost_price" label="参考价" align="center"></el-table-column>
        <el-table-column v-if="!is_assign" prop="stockRemoval" label="出库价" align="center"></el-table-column>
        <el-table-column v-else prop="stockRemovals" label="出库价" align="center"></el-table-column>
        <el-table-column v-if="!is_assign" prop="totalPrices" label="出库价总价" align="center"></el-table-column>
        <el-table-column v-else prop="totalPricess" label="出库价总价" align="center"></el-table-column>
        <el-table-column prop="rk_spec" label="箱规" align="center"></el-table-column>
        <el-table-column prop="order_num" label="数量" align="center"></el-table-column>
        <el-table-column prop="markup" label="加价" align="center"></el-table-column>
        <el-table-column prop="box_qty" label="件数" align="center"></el-table-column>
        <el-table-column v-if="!is_assign" label="预提" align="center" width="150px">
          <template slot-scope="scope">
            <div>{{ scope.row.withholding_fee }}</div>
          </template>
        </el-table-column>
        <el-table-column v-else label="预提" align="center" width="150px">
          <template slot-scope="scope">
            <div>{{ scope.row.withholding_fee2 }}</div>
          </template>
        </el-table-column>
        <el-table-column prop="description" label="备注" align="center"></el-table-column>
        <el-table-column prop="package.name" label="包装箱" align="center"></el-table-column>
        <el-table-column prop="package_box_spec" label="包装箱规格" align="center"></el-table-column>
      </el-table>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="confirm">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import { findOrderInfo, editOrderInfo } from "@/api/superOrder/superOrderList";
export default {
  props: {
    particularsDialogs: Object,
  },
  data() {
    return {
      tableData: [],
      is_assign: false,
    };
  },
  methods: {
    confirm() {
      this.particularsDialogs.centerDialogVisible = false;
    },
    getData() {
      let data = {
        id: this.particularsDialogs.id,
      };
      findOrderInfo(data).then((res) => {
        if (res.code == 0) {
          res.data.info.order_goods.forEach((result) => {
            result.purchasePrice = result.buyerprofit_price;
            result.purchasePrices = result.buyerprofit_price2;
            result.stockRemoval = (
              parseFloat(result.avg_price) +
              parseFloat(result.markup) +
              parseFloat(result.withholding_fee) +
              parseFloat(result.purchasePrice)
            ).toFixed(4);
            result.totalPrices = (
              result.stockRemoval * result.order_num
            ).toFixed(4);

            result.stockRemovals = (
              parseFloat(result.cost_price) +
              parseFloat(result.markup2) +
              parseFloat(result.withholding_fee2) +
              parseFloat(result.purchasePrices)
            ).toFixed(4);
            result.totalPricess = (
              result.stockRemovals * result.order_num
            ).toFixed(4);
          });
          this.is_assign = res.data.info.is_assign;
          this.tableData = res.data.info.order_goods;
        }
      });
    },
    //每页多少条
    handleCurrentChange(val) {
      this.pageData.page = 1;
      this.pageData.pageSize = val;
      this.getData();
    },
    //选取页数
    handleSizeChange(page) {
      this.pageData.page = page;
      this.getData();
    },
  },
};
</script>
<style scoped>
.pagination {
  text-align: right;
  padding: 10px;
}
</style>